package cn.pro.javafxlearn;

import javafx.application.Application;
import javafx.scene.ImageCursor;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

public class Main3 extends Application {
    public static void main(String[] args) {
          Application.launch(args);
    }
    @Override
    public void start(Stage primaryStage) throws Exception {
        //第一个场景
        Button button1=new Button("hellow world");
        button1.setLayoutX(400);//场景的坐标
        button1.setLayoutY(400);
        AnchorPane root=new AnchorPane();
        root.getChildren().addAll(button1);
        Scene scene=new Scene(root,500,500);

        //第二个场景
        Label label =new Label("你好世界");
        label.setLayoutX(200);
        label.setLayoutY(200);
        Button button2=new Button("返回原场景");
        button2.setLayoutX(200);
        button2.setLayoutY(300);
        AnchorPane root1=new AnchorPane();
        root1.getChildren().addAll(label,button2);
        Scene scene1=new Scene(root1,500,500);
        scene1.setCursor(new ImageCursor(new Image("imagee/2.png")));//设置第二个场景的鼠标光标

        button1.setOnAction(event -> {//设置场景1中的按钮点击事件，切换到场景2
            primaryStage.setScene(scene1);
        });

        button2.setOnAction(event -> {//设置场景2中的按钮点击事件，却换到场景1
            primaryStage.setScene(scene);
        });

        primaryStage.setScene(scene);
        primaryStage.setTitle("hello");
        primaryStage.setResizable(false);
        primaryStage.show();
    }
}
